To start to use spsComps, load it in your Shiny app file or Rmarkdown file
library(spsComps)
## Loading required package: shiny
## Loading required package: spsUtil
So you can see it depends on shiny and spsUtil. When you load it, there is no need to additionally load shiny or spsUtil.
For most of the UI components, you can view them in the online Shiny demo. Here we just select a few to demonstrate how you can use them in a R markdown.
spsGoTopA go top button.
spsGoTop()
It will not be display inline of the Rmd, just simply call it and maybe change the style as you want. By default, a “go to top” button will be created on the bottom-right corner. Now scroll this page, and you should see it (the rocket button).
gallerytexts <- c("p1", "p2", "", "p4", "p5")
hrefs <- c("https://github.com/lz100/spsComps/blob/master/img/1.jpg?raw=true",
"https://github.com/lz100/spsComps/blob/master/img/2.jpg?raw=true",
"",
"https://github.com/lz100/spsComps/blob/master/img/4.jpg?raw=true",
"https://github.com/lz100/spsComps/blob/master/img/5.jpg?raw=true")
images <- c("https://github.com/lz100/spsComps/blob/master/img/1.jpg?raw=true",
"https://github.com/lz100/spsComps/blob/master/img/2.jpg?raw=true",
"https://github.com/lz100/spsComps/blob/master/img/3.jpg?raw=true",
"https://github.com/lz100/spsComps/blob/master/img/4.jpg?raw=true",
"https://github.com/lz100/spsComps/blob/master/img/5.jpg?raw=true")
gallery(
texts = texts, hrefs = hrefs, images = images,
enlarge = TRUE,
enlarge_method = "modal"
)
You can show a gallery of plots you make in the Rmd and when people click it, it will be enlarged. You can also specify a link for each image.
hexLogohexLogo(
"logo", "Logo",
hex_img = "https://live.staticflickr.com/7875/46106952034_954b8775fa_b.jpg",
hex_link = "https://www.google.com",
footer = "Footer",
footer_link = "https://www.google.com"
)
hexPanelspsCodeBtnmy_code <-
'
# load package and data
library(ggplot2)
data(mpg, package="ggplot2")
# mpg <- read.csv("http://goo.gl/uEeRGu")
# Scatterplot
theme_set(theme_bw()) # pre-set the bw theme.
g <- ggplot(mpg, aes(cty, hwy))
g + geom_jitter(width = .5, size=1) +
labs(subtitle="mpg: city vs highway mileage",
y="hwy",
x="cty",
title="Jittered Points")
'
spsCodeBtn(id = "a", my_code)
spsCodeBtn(id = "c", my_code, display = "collapse")